class Article < ActiveRecord::Base
  include LogicalDestroy
  has_many :article_categories,autosave: true
  has_many :categories,through: :article_categories
  has_many :article_tags,autosave: true
  has_many :tags ,through: :article_tags

  def include_tag?(tag)
    if !self.tags.nil?
      self.tags.each do |t|
        if t.id == tag.id
          return true
        end
      end
    end
    return false
  end

  def include_category?(category)
    if !self.categories.nil?
      self.categories.each do |t|
        if t.id == category.id
          return true
        end
      end
    end
    return false
  end
end
